<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    window.onload = function() {
        var user = document.getElementById('user');
        var pwd = document.getElementById('pwd');
        user.onblur = function() {

            xhr = new XMLHttpRequest();
            var url = 'user=' + user.value + '&pwd=' + pwd.value;
            xhr.open('post', './post.php');
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(url);
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    document.getElementById('hh').innerHTML = xhr.responseText;
                    // console.log(xhr.responseText);
                }
            }
        }
    }
</script>

<body>
    <form action="">
        用户名 <input type="text" name="" id="user">
        <br/> 密码： <input type="text" name="" id="pwd">
        <br/>
        <span id="hh"></span>
        <!-- <input type="button" value=""> -->
    </form>
</body>

</html>